iT邦幫忙

2019 iT 邦幫忙鐵人賽

DAY 3
1
自我挑戰組

DevOps學習之旅系列 第 3

Day 3 Pyramid 專案說明

  • 分享至 

  • xImage
  •  

簡介

上一篇創建專案之後,再來是需要在 bitbucket 創建遠端 Repository,並把我們的專案上傳,再來安裝 PyCharm IDE,這個IDE個人覺得很好用,專門為 python 寫的IDE,而且還有免費版本可以使用,非常的佛心,最後會介紹 Pyramid 專案基本的檔案介紹.

bitbucket

bitbucket 首頁

bitbucket 個人頁
https://ithelp.ithome.com.tw/upload/images/20181003/20072651Einwj1tZ5n.png

創建專案
https://ithelp.ithome.com.tw/upload/images/20181003/20072651xbCzbnCBQ0.png

Ithome_pellok_2018 專案
https://ithelp.ithome.com.tw/upload/images/20181003/20072651dsqUzMmMeU.png

git 加入 bitbucket 遠端專案,把專案更新到 bitbucket

cd ithome_pellok_2018
git remote add origin https://pellok2002@bitbucket.org/pellok2002/ithome_pellok_2018.git
git push -u origin master

pycharm

下載 SourceTree for Mac
https://ithelp.ithome.com.tw/upload/images/20181004/20072651QvZkQccOJa.png

目錄區
https://ithelp.ithome.com.tw/upload/images/20181004/20072651kdnbTHRwPw.png

常用功能 向右三角型:執行,爬蟲:為Debug模式執行,基本上開發都是用爬蟲模式
https://ithelp.ithome.com.tw/upload/images/20181004/2007265100VQJG05iy.png

Debug 頁面
https://ithelp.ithome.com.tw/upload/images/20181004/20072651Qznz9hHZsv.png

https://ithelp.ithome.com.tw/upload/images/20181004/20072651PZ8oq1nX49.png

專案說明

基本上 Pyramid 專案已經提供一個完整的網頁 MV C架構,包含 Router Controller、Sqlalchemy ORM、View Template,甚至還有測試功能,以下來介紹專案檔案,讓大家對 pyramid 框架有基礎的暸解.

pip 模組

setup.py : 模組定義檔
CHANGES.txt : 版本更動紀錄
MANIFEST.in : 這個不太清楚XD
README.txt : 讀我

設定檔

development.ini : 開發環境設定檔
production.ini : 正式環境設定檔

程式起始點

ithome_pellok_2018/init.py : 主程式

Sqlalchemy ORM

ithome_pellok_2018.sqlite : DB
ithome_pellok_2018/models/init.py : ORM程式
ithome_pellok_2018/models/meta.py : ORM程式
ithome_pellok_2018/models/mymodel.py : ORM 表定義
ithome_pellok_2018/initializedb.py : 初始化DB程式

Router Controller

ithome_pellok_2018/routes.py : 路由
ithome_pellok_2018/views/default.py : 路由程式
ithome_pellok_2018/views/notfound.py : 404 頁面路由

View Template

ithome_pellok_2018/static/* : 靜態路進檔案
ithome_pellok_2018/templates/404.jinja2 : 404 頁面
ithome_pellok_2018/templates/layout.jinja2 : 樣板基礎頁
ithome_pellok_2018/templates/mytemplate.jinja2 : 首頁

Test

pytest.ini : 測試設定檔
.coveragerc : 覆蓋率報告
ithome_pellok_2018/tests.py : 測試主程式

結論

在這邊每個檔案都有相對應的功能,而且都是很重要的基礎頁面,建議想要暸解的 pyramid 框架的朋友們,一定要搞懂這邊每一個檔案的內容,因為會很長的使用到.

參考

官方教學


上一篇
Day 2 起手式
下一篇
Day 4 系統開發
系列文
DevOps學習之旅30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

1 則留言

0
elecbuggy
iT邦新手 5 級 ‧ 2018-10-04 16:49:22

比起Flask跟Django,
我很少看到別人在討論pyramid耶!
還滿期待後續的文章的~加油

pellok iT邦新手 3 級 ‧ 2018-10-04 23:10:50 檢舉

哈哈~真的很少,但是覺得還蠻好用的.

我要留言

立即登入留言